package org.bbsoft.catchme.model.entities;

import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "USERS")
public class User {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "USER_ID", nullable = false)
	private Long id;

	@Basic(optional = false)
	@Column(name = "NAME")
	private String name;

	/** Events to which user is invited */
	@ManyToMany(mappedBy = "invitedUsers")
	private List<Event> invitations;

	/** The accepted events by the user */
	@ManyToMany(mappedBy = "acceptingUsers")
	private List<Event> acceptedInvitations;

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner", orphanRemoval = true, fetch = FetchType.EAGER)
	private List<Event> ownedEvents;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Event> getInvitations() {
		return invitations;
	}

	public void setInvitations(List<Event> invitations) {
		this.invitations = invitations;
	}

	public List<Event> getAcceptedInvitations() {
		return acceptedInvitations;
	}

	public void setAcceptedInvitations(List<Event> acceptedInvitations) {
		this.acceptedInvitations = acceptedInvitations;
	}

	public List<Event> getOwnedEvents() {
		return ownedEvents;
	}

	public void setOwnedEvents(List<Event> ownedEvents) {
		this.ownedEvents = ownedEvents;
	}

}
